package cn.itcast.web.controller.stat;

import cn.itcast.service.stat.StatService;
import cn.itcast.web.controller.BaseController;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @author LT
 * @version 1.0.0
 * @ClassName StatController.java
 * @Description TODO 统计控制器
 * @createTime 2020年04月07日 22:20:00
 */
@Controller
@RequestMapping("/stat")
public class StatController extends BaseController {

    @Reference
    private StatService statService;

    /**
     * @param chartsType
     * @return
     */
    @RequestMapping("/toCharts")
    public String toCharts(String chartsType) {
        return "stat/stat-" + chartsType;
    }

    /**
     * 获取厂家的销售情况
     *
     * @param chartsType
     * @return
     */
    @RequestMapping("/getFactoryData")
    @ResponseBody
    public List<Map<String, Object>> getFactoryData(String chartsType) {
        return statService.getFactoryData(getLoginCompanyId());
    }

    /**
     * 作用： 获取产品销售的前五名数据
     * url: /stat/getSellData
     * 返回： 获取产品销售的前五名数据，json格式
     */
    @RequestMapping("/getSellData")
    @ResponseBody
    public List<Map<String, Object>> getSellData(String chartsType) {
        return statService.getSellData(getLoginCompanyId());
    }

    /**
     * 获取系统访问压力数据
     *
     * @param chartsType
     * @return
     */
    @RequestMapping("/getOnLineData")
    @ResponseBody
    public List<Map<String, Object>> getOnLineData(String chartsType) {
        return statService.getOnLineData(getLoginCompanyId());
    }

}
